home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / prg_casm / snip9611.zip / CTRLPRNT.C < prev    next >
C/C++ Source or Header  |  1996-11-24  |  895b  |  46 lines

  1. /* +++Date last modified: 02-Nov-1995 */
  2.  
  3. /*
  4. **  Print a line of text, displaying Ctrl characters using leading carets
  5. **  public domain by Bob Stout
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include "ctrlprnt.h"
  11.  
  12. void ctrl_print(char *line)
  13. {
  14.       while (*line)
  15.       {
  16.             if (' ' > *line)
  17.             {
  18.                   putchar('^');
  19.                   putchar('@' + (*line++));
  20.             }
  21.             else  putchar(*line++);
  22.       }
  23.       if (!strcmp((line - 2), "\x0d\x0a") || !strcmp((line - 2), "\x0a\x0d"))
  24.             putchar('\n');
  25. }
  26.  
  27. #ifdef TEST
  28.  
  29. #include <stdlib.h>
  30. #include <ctype.h>
  31.  
  32. main()
  33. {
  34.       char *p, *test = "This is a test";
  35.  
  36.       for (p = strupr(test); *p; ++p)
  37.       {
  38.             if (isalpha(*p))
  39.                   *p = *p - 64;
  40.       }
  41.       ctrl_print(test);
  42.       return EXIT_SUCCESS;
  43. }
  44.  
  45. #endif /* TEST */
  46.